package org.springblade.modules.admin.service.impl;

import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.AllArgsConstructor;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.admin.dto.PlanCheckStatisticsQueryDTO;
import org.springblade.modules.admin.entity.ElevatorPrincipalDept;
import org.springblade.modules.admin.entity.MaintainPlanContent;
import org.springblade.modules.admin.entity.MaintainPlanContentUser;
import org.springblade.modules.admin.entity.MaintainPlanUserDayCount;
import org.springblade.modules.admin.enums.*;
import org.springblade.modules.admin.mapper.MaintainPlanUserDayCountMapper;
import org.springblade.modules.admin.service.*;
import org.springblade.modules.admin.vo.CheckStatisticsTrendVO;
import org.springblade.modules.system.service.IDeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

@AllArgsConstructor
@Service
public class MaintainPlanUserDayCountServiceImpl extends BaseServiceImpl<MaintainPlanUserDayCountMapper, MaintainPlanUserDayCount> implements MaintainPlanUserDayCountService{

	private final IMaintainPlanContentService planContentService;
	private final IMaintainPlanContentUserService planContentUserService;
	private final IMaintainSignService signService;
	private final IDeptService deptService;
	private final ElevatorPrincipalDeptService elevatorPrincipalDeptService;

	@Override
	@Transactional(rollbackFor = Exception.class)
	public void updatePlanUserDayCount(Integer typeStatus) {

		String startTime = DateUtil.format(DateUtil.yesterday(),"yyyy-MM-dd")+" 01:00:00";
		String endTime = DateUtil.format(DateUtil.date(),"yyyy-MM-dd")+" 01:00:00";

		List<MaintainPlanUserDayCount> resultList = new ArrayList<>();
		List<MaintainPlanContent> planContentList = planContentService.listPlanForCount(typeStatus,startTime,endTime);
		if(ObjectUtil.isNotEmpty(planContentList)){
			List<Long> planIds = planContentList.stream().map(MaintainPlanContent::getId).collect(Collectors.toList());
			List<MaintainPlanContentUser> planUserList = planContentUserService.listByPlanId(planIds);
			planContentList.forEach(e -> {
				Integer duration = 0;
				if(!e.getStatus().equals(TaskStatusEnum.BY_DISABLE.getStatus())){
					// 时长 正常 过长 过短
					if(e.getWorkTime().compareTo(BigDecimal.valueOf(15)) < 0){
						duration = 3;
					}else if(e.getWorkTime().compareTo(BigDecimal.valueOf(60)) > 0){
						duration = 2;
					}else {
						duration = 1;
					}
				}
				Integer finalDuration = duration;
				planUserList.forEach(j -> {
					if(e.getId().equals(j.getPlanId())){
						MaintainPlanUserDayCount planUserDayCount = new MaintainPlanUserDayCount();
						planUserDayCount.setPlanId(e.getId());
						planUserDayCount.setPlanStatus(e.getStatus());
						planUserDayCount.setPlanType(e.getTypeStatus());
						planUserDayCount.setElevatorId(e.getElevatorId());
						planUserDayCount.setUserId(j.getUserId());
						planUserDayCount.setUserDeptIds(j.getDeptIds());
						planUserDayCount.setUserRoleIds(j.getRoleIds());
						planUserDayCount.setWorkTime(j.getWorkTime());
						planUserDayCount.setSignNormal(j.getSignNormal());
						planUserDayCount.setSignOutNormal(j.getSignOutNormal());
						planUserDayCount.setSignError(j.getSignError());
						planUserDayCount.setSignOutError(j.getSignOutError());
						planUserDayCount.setSignSystem(j.getSignSystem());
						planUserDayCount.setDuration(finalDuration);
						planUserDayCount.setTenantId(e.getTenantId());
						planUserDayCount.setStartTime(e.getStartTime());
						planUserDayCount.setEndTime(e.getEndTime());
						// 时效性 及时 超时
						if(ObjectUtil.isNotEmpty(e.getOverdueDay()) && e.getOverdueDay() > 0){
							planUserDayCount.setTimeliness(2);
						}else {
							planUserDayCount.setTimeliness(1);
						}
						// 逾期 1-正常 2-逾期
						planUserDayCount.setOverdue(PlanOverdueEnum.NORMAL.getId());
						if(e.getAuditType().equals(PlanAuditTypeEnum.AUDIT.getStatus())){
							if(e.getStatus().equals(TaskStatusEnum.BY_SIGN.getStatus()) || e.getStatus().equals(TaskStatusEnum.BY_MAINTAIN_SIGN.getStatus())){
								long planOverdueDate = e.getPlanOverdueDate().getTime();
								long maintainSignatureTime = DateUtil.parse(DateUtil.format(e.getMaintainSignatureTime(),"yyyy-MM-dd")).getTime();
								if(maintainSignatureTime > planOverdueDate){
									planUserDayCount.setOverdue(PlanOverdueEnum.OVERDUE.getId());
								}
							}else {
								long nowDate = DateUtil.parse(DateUtil.format(DateUtil.yesterday(),"yyyy-MM-dd")).getTime();
								long elevatorOverdueDate = e.getElevatorOverdueDate().getTime();
								long planDate = e.getPlanDate().getTime();
								if(planDate <= nowDate && nowDate > elevatorOverdueDate){
									planUserDayCount.setOverdue(PlanOverdueEnum.OVERDUE.getId());
								}
							}
						}

						planUserDayCount.setRecordDate(DateUtil.yesterday());
						resultList.add(planUserDayCount);
					}
				});
			});
			List<List<MaintainPlanUserDayCount>> p = ListUtil.partition(resultList,50);
			p.forEach(super::saveBatch);
		}

	}

	@Override
	@Transactional(rollbackFor = Exception.class)
	public void updateCheckPlanUserDayCount() {

		// 查询所有在任务计划时间到现在为止状态未改变工单
		List<MaintainPlanUserDayCount> inPlanDate = planContentUserService.listInPlanDate();
		if (ObjectUtil.isNotEmpty(inPlanDate)){
			inPlanDate.forEach(e -> {
				e.setRecordDate(e.getPlanDate());
				if(e.getPlanStatus().equals(TaskStatusEnum.BY_SIGN.getStatus())){
					e.setTimeliness(1);
				}else {
					e.setTimeliness(2);
				}
			});
		}
		List<MaintainPlanUserDayCount> result = new ArrayList<>(inPlanDate);

		// 查询所有在任务计划时间到现在为止状态已改变工单
		List<MaintainPlanUserDayCount> notInPlanDate = planContentUserService.listNotInPlanDate();
		if (ObjectUtil.isNotEmpty(notInPlanDate)){
			notInPlanDate.forEach(e -> {
				e.setRecordDate(e.getUpdateTime());
				e.setTimeliness(2);
			});
		}
		result.addAll(notInPlanDate);
		super.saveBatch(result);
	}

	public static void main(String[] args) {
		getDatesBetweenByDay(localDate("2022-05-01"),localDate("2022-08-21")).forEach(date -> {
			System.err.println(DateUtil.format(date,"yyyy-MM-dd"));
		});
	}

	/**
	 * String 转 LocalDate
	 * @param date yyyy-MM-dd
	 * @return
	 */
	public static LocalDate localDate(String date) {
		return LocalDate.parse(date, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
	}

	/**
	 * Date 转 LocalDate
	 * @param date yyyy-MM-dd
	 * @return
	 */
	public static LocalDate localDate(Date date) {
		return date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
	}


	/**
	 * 获取指定时间段所有日期
	 * @param startDate
	 * @param endDate
	 * @return
	 */
	public static List<Date> getDatesBetweenByDay(LocalDate startDate, LocalDate endDate) {
		long numOfDaysBetween = ChronoUnit.DAYS.between(startDate, endDate) + 1;
		return IntStream.iterate(0, i -> i + 1)
			.limit(numOfDaysBetween)
			.mapToObj(i -> Date.from(startDate.plusDays(i).atStartOfDay(ZoneId.systemDefault()).toInstant()))
			.collect(Collectors.toList());
	}

	@Override
	public void updateWxPlanUserDayCount(String typeStatus) {
		List<MaintainPlanUserDayCount> resultList = new ArrayList<>();
		List<MaintainPlanContent> planContentList = planContentService.listWxPlanForCount(typeStatus);
		if (ObjectUtil.isNotEmpty(planContentList)) {
			List<Long> planIds = planContentList.stream().map(MaintainPlanContent::getId).collect(Collectors.toList());
			List<MaintainPlanContentUser> planUserList = planContentUserService.listByWxPlanId(planIds);
			planContentList.forEach(e -> {
				planUserList.forEach(j -> {
					if (e.getId().equals(j.getPlanId())) {
						MaintainPlanUserDayCount planUserDayCount = new MaintainPlanUserDayCount();
						planUserDayCount.setPlanId(e.getId());
						planUserDayCount.setPlanStatus(e.getStatus());
						planUserDayCount.setPlanType(e.getTypeStatus());
						planUserDayCount.setElevatorId(e.getElevatorId());
						planUserDayCount.setUserId(j.getUserId());
						planUserDayCount.setUserDeptIds(j.getDeptIds());
						planUserDayCount.setUserRoleIds(j.getRoleIds());
						planUserDayCount.setWorkTime(j.getWorkTime());
						planUserDayCount.setSignNormal(j.getSignNormal());
						planUserDayCount.setSignOutNormal(j.getSignOutNormal());
						planUserDayCount.setSignError(j.getSignError());
						planUserDayCount.setSignOutError(j.getSignOutError());
						planUserDayCount.setSignSystem(j.getSignSystem());
						planUserDayCount.setTenantId(e.getTenantId());
						planUserDayCount.setStartTime(e.getStartTime());
						planUserDayCount.setEndTime(e.getEndTime());
						planUserDayCount.setRecordDate(DateUtil.yesterday());
						resultList.add(planUserDayCount);
					}
				});
			});
			super.saveBatch(resultList);
		}
	}

	@Override
	public void wxHistoryAddDayCount() {
		List<MaintainPlanUserDayCount> resultList = new ArrayList<>();
		List<MaintainPlanContentUser> planUserList = baseMapper.wxHistoryAddDayCount();
		planUserList.forEach(planUser -> {
			MaintainPlanUserDayCount maintainPlanUserDayCount = new MaintainPlanUserDayCount();
			maintainPlanUserDayCount.setPlanId(planUser.getPlanId());
			maintainPlanUserDayCount.setPlanType(MaintainPlanContentEnum.MAINTAIN_WX.getId());
			maintainPlanUserDayCount.setElevatorId(planUser.getElevatorId());
			maintainPlanUserDayCount.setUserId(planUser.getUserId());
			maintainPlanUserDayCount.setUserDeptIds(planUser.getDeptIds());
			maintainPlanUserDayCount.setUserRoleIds(planUser.getRoleIds());
			maintainPlanUserDayCount.setTenantId(planUser.getTenantId());

			if (!Func.equalsSafe(DateUtil.format(planUser.getPlanDate(), "yyyy-MM-dd"), DateUtil.format(planUser.getPlanEndTime(), "yyyy-MM-dd"))) {
				// 若任务不是当天完成
				MaintainPlanUserDayCount beginPlanUserDayCount = ObjectUtil.cloneByStream(maintainPlanUserDayCount);
				beginPlanUserDayCount.setPlanStatus(TaskStatusEnum.WX_TO_START.getStatus());
				beginPlanUserDayCount.setRecordDate(planUser.getPlanDate());
				resultList.add(beginPlanUserDayCount);
			}

			maintainPlanUserDayCount.setPlanStatus(TaskStatusEnum.WX_SIGN_FINISH.getStatus());
			maintainPlanUserDayCount.setWorkTime(planUser.getWorkTime());
			maintainPlanUserDayCount.setSignNormal(planUser.getSignNormal());
			maintainPlanUserDayCount.setSignOutNormal(planUser.getSignOutNormal());
			maintainPlanUserDayCount.setSignError(planUser.getSignError());
			maintainPlanUserDayCount.setSignOutError(planUser.getSignOutError());
			maintainPlanUserDayCount.setSignSystem(planUser.getSignSystem());
			maintainPlanUserDayCount.setStartTime(planUser.getPlanBeginTime());
			maintainPlanUserDayCount.setEndTime(planUser.getPlanEndTime());
			maintainPlanUserDayCount.setRecordDate(planUser.getPlanEndTime());
			resultList.add(maintainPlanUserDayCount);
		});

		super.saveBatch(resultList);
	}

	@Override
	public List<CheckStatisticsTrendVO> selectCheckTrendEntiretyStatus(PlanCheckStatisticsQueryDTO queryDTO) {
//		String[] initTypeArr = {"待开始","进行中","提交任务","维保签字","已完成"};
		String[] initTypeArr = {"待开始","未完成","已完成"};
		List<CheckStatisticsTrendVO> result = this.initTrendEntirety(queryDTO,initTypeArr);
		List<Long> allDeptIds = deptService.selectDeptAndAllChildIds(queryDTO.getDeptIds());
		List<ElevatorPrincipalDept> elevatorList = elevatorPrincipalDeptService.list(Wrappers.<ElevatorPrincipalDept>lambdaQuery().in(ElevatorPrincipalDept::getDeptId,allDeptIds));
		List<MaintainPlanUserDayCount> planUserDayCounts = new ArrayList<>();
		if(Func.isNotEmpty(elevatorList)){
			queryDTO.setElevatorIds(elevatorList.stream().map(ElevatorPrincipalDept::getElevatorId).distinct().collect(Collectors.toList()));
			planUserDayCounts = baseMapper.selectPlanStatusByUserDate(queryDTO);
		}
		if(ObjectUtil.isNotEmpty(planUserDayCounts)){
			Map<String,List<MaintainPlanUserDayCount>> dateGroup;
			if(queryDTO.getDataType().equals(1)){
				// 日
				dateGroup = planUserDayCounts.stream().collect(Collectors.groupingBy(t -> DateUtil.format(t.getPlanDate(),"yyyy/M/d")));
			}else if(queryDTO.getDataType().equals(2)){
				// 周
				dateGroup = planUserDayCounts.stream().collect(Collectors.groupingBy(t -> String.format("%s~%s",DateUtil.format(DateUtil.beginOfWeek(t.getPlanDate()), "yyyy/M/d"), DateUtil.format(DateUtil.endOfWeek(t.getPlanDate()), "yyyy/M/d"))));
			}else {
				// 月
				dateGroup = planUserDayCounts.stream().collect(Collectors.groupingBy(t -> String.format("%s月",DateUtil.format(t.getPlanDate(), "yyyy年M"))));
			}
			result.forEach(e -> dateGroup.forEach((k, v) -> {

				// 工单数量
				long planNum = 0L;
				if(e.getType().equals(initTypeArr[0])){
					planNum = v.stream().filter(t -> t.getPlanStatus().equals(TaskStatusEnum.BY_DISABLE.getStatus())).map(MaintainPlanUserDayCount::getPlanId).distinct().count();
				}else if(e.getType().equals(initTypeArr[1])) {
					planNum = v.stream().filter(t -> t.getPlanStatus().equals(TaskStatusEnum.BY_PROCESSED.getStatus()) || t.getPlanStatus().equals(TaskStatusEnum.BY_FINISH.getStatus())).map(MaintainPlanUserDayCount::getPlanId).distinct().count();
				}else if(e.getType().equals(initTypeArr[2])) {
					planNum = v.stream().filter(t -> t.getPlanStatus().equals(TaskStatusEnum.BY_MAINTAIN_SIGN.getStatus()) || t.getPlanStatus().equals(TaskStatusEnum.BY_SIGN.getStatus())).map(MaintainPlanUserDayCount::getPlanId).distinct().count();
				}
				e.getTrendData().put(k,BigDecimal.valueOf(planNum));
			}));
		}
		return result;
	}

	@Override
	public List<CheckStatisticsTrendVO> selectCheckTrendEntiretyTimeliness(PlanCheckStatisticsQueryDTO queryDTO) {
		String[] initTypeArr = {"及时","超时","及时率"};
		List<CheckStatisticsTrendVO> result = this.initTrendEntirety(queryDTO,initTypeArr);
		List<Long> allDeptIds = deptService.selectDeptAndAllChildIds(queryDTO.getDeptIds());
		List<ElevatorPrincipalDept> elevatorList = elevatorPrincipalDeptService.list(Wrappers.<ElevatorPrincipalDept>lambdaQuery().in(ElevatorPrincipalDept::getDeptId,allDeptIds));
		List<MaintainPlanUserDayCount> planUserDayCounts = new ArrayList<>();
		if(Func.isNotEmpty(elevatorList)){
			queryDTO.setElevatorIds(elevatorList.stream().map(ElevatorPrincipalDept::getElevatorId).distinct().collect(Collectors.toList()));
			planUserDayCounts = baseMapper.selectPlanTimelinessByUserDate(queryDTO);
		}
		if(ObjectUtil.isNotEmpty(planUserDayCounts)){
			Map<String,List<MaintainPlanUserDayCount>> dateGroup;
			if(queryDTO.getDataType().equals(1)){
				// 日
				dateGroup = planUserDayCounts.stream().collect(Collectors.groupingBy(t -> DateUtil.format(t.getPlanDate(),"yyyy/M/d")));
			}else if(queryDTO.getDataType().equals(2)){
				// 周
				dateGroup = planUserDayCounts.stream().collect(Collectors.groupingBy(t -> String.format("%s~%s",DateUtil.format(DateUtil.beginOfWeek(t.getPlanDate()), "yyyy/M/d"), DateUtil.format(DateUtil.endOfWeek(t.getPlanDate()), "yyyy/M/d"))));
			}else {
				// 月
				dateGroup = planUserDayCounts.stream().collect(Collectors.groupingBy(t -> String.format("%s月",DateUtil.format(t.getPlanDate(), "yyyy年M"))));
			}
			result.forEach(e -> dateGroup.forEach((k, v) -> {

				// 工单数量
				if(e.getType().equals(initTypeArr[0])){
					long planNum = v.stream().filter(t -> t.getTimeliness().equals(1)).map(MaintainPlanUserDayCount::getPlanId).distinct().count();
					e.getTrendData().put(k,BigDecimal.valueOf(planNum));
				}else if(e.getType().equals(initTypeArr[1])) {
					long planNum = v.stream().filter(t -> t.getTimeliness().equals(2)).map(MaintainPlanUserDayCount::getPlanId).distinct().count();
					e.getTrendData().put(k,BigDecimal.valueOf(planNum));
				}else if(e.getType().equals(initTypeArr[2])){
					long planTotal = v.stream().map(MaintainPlanUserDayCount::getPlanId).distinct().count();
					if(planTotal > 0){
						long planNum = v.stream().filter(t -> t.getTimeliness().equals(1)).map(MaintainPlanUserDayCount::getPlanId).distinct().count();
						e.getTrendData().put(k,String.format("%.1f%%", NumberUtil.mul(NumberUtil.div(planNum, planTotal), 100)));
					}
				}
			}));
		}
		return result;
	}

	@Override
	public List<CheckStatisticsTrendVO> selectCheckTrendEntiretyOverdue(PlanCheckStatisticsQueryDTO queryDTO) {
		String[] initTypeArr = {"未逾期","已逾期"};
		List<CheckStatisticsTrendVO> result = this.initTrendEntirety(queryDTO,initTypeArr);
		List<Long> allDeptIds = deptService.selectDeptAndAllChildIds(queryDTO.getDeptIds());
		List<ElevatorPrincipalDept> elevatorList = elevatorPrincipalDeptService.list(Wrappers.<ElevatorPrincipalDept>lambdaQuery().in(ElevatorPrincipalDept::getDeptId,allDeptIds));
		List<MaintainPlanUserDayCount> planUserDayCounts = new ArrayList<>();
		if(Func.isNotEmpty(elevatorList)){
			queryDTO.setElevatorIds(elevatorList.stream().map(ElevatorPrincipalDept::getElevatorId).distinct().collect(Collectors.toList()));
			planUserDayCounts = baseMapper.selectPlanOverdueByUserDate(queryDTO);
		}
		if(ObjectUtil.isNotEmpty(planUserDayCounts)){
			planUserDayCounts = planUserDayCounts.stream().filter(e -> e.getPlanAuditType().equals(PlanAuditTypeEnum.AUDIT.getStatus())).collect(Collectors.toList());
			Map<String,List<MaintainPlanUserDayCount>> dateGroup;
			if(queryDTO.getDataType().equals(1)){
				// 日
				dateGroup = planUserDayCounts.stream().collect(Collectors.groupingBy(t -> DateUtil.format(t.getPlanDate(),"yyyy/M/d")));
			}else if(queryDTO.getDataType().equals(2)){
				// 周
				dateGroup = planUserDayCounts.stream().collect(Collectors.groupingBy(t -> String.format("%s~%s",DateUtil.format(DateUtil.beginOfWeek(t.getPlanDate()), "yyyy/M/d"), DateUtil.format(DateUtil.endOfWeek(t.getPlanDate()), "yyyy/M/d"))));
			}else {
				// 月
				dateGroup = planUserDayCounts.stream().collect(Collectors.groupingBy(t -> String.format("%s月",DateUtil.format(t.getPlanDate(), "yyyy年M"))));
			}
			result.forEach(e -> dateGroup.forEach((k, v) -> {

				// 工单数量
				long planNum = 0L;
				if(e.getType().equals(initTypeArr[0])){
					planNum = v.stream().filter(t -> ObjectUtil.isNotEmpty(t.getOverdue()) && t.getOverdue().equals(PlanOverdueEnum.NORMAL.getId())).map(MaintainPlanUserDayCount::getPlanId).distinct().count();
				}else if(e.getType().equals(initTypeArr[1])) {
					planNum = v.stream().filter(t -> ObjectUtil.isNotEmpty(t.getOverdue()) && t.getOverdue().equals(PlanOverdueEnum.OVERDUE.getId())).map(MaintainPlanUserDayCount::getPlanId).distinct().count();
				}
				e.getTrendData().put(k,BigDecimal.valueOf(planNum));
			}));
		}
		return result;
	}

	/**
	 * 初始化保养趋势整体数据
	 * @param queryDTO
	 * @param initTypeArr
	 * @return
	 */
	private List<CheckStatisticsTrendVO> initTrendEntirety(PlanCheckStatisticsQueryDTO queryDTO, String[] initTypeArr) {
		List<CheckStatisticsTrendVO> initList = new ArrayList<>();
		for (String initType: initTypeArr) {
			CheckStatisticsTrendVO init = new CheckStatisticsTrendVO();
			init.setType(initType);
			Map<String,Object> trendData = new LinkedHashMap<>(32);
			if(queryDTO.getDataType().equals(1)){
				// 日
				List<DateTime> rangeDate = DateUtil.rangeToList(DateUtil.parse(queryDTO.getStartDate()), DateUtil.parse(queryDTO.getEndDate()), DateField.DAY_OF_YEAR);
				rangeDate.forEach(date -> {
					trendData.put(DateUtil.format(date, "yyyy/M/d"), BigDecimal.ZERO);
				});
			}else if(queryDTO.getDataType().equals(2)){
				// 周
				List<DateTime> rangeDate = DateUtil.rangeToList(DateUtil.parse(queryDTO.getStartDate()), DateUtil.parse(queryDTO.getEndDate()), DateField.DAY_OF_YEAR);
				rangeDate.forEach(date -> {
					String weekDate = String.format("%s~%s",DateUtil.format(DateUtil.beginOfWeek(date), "yyyy/M/d"), DateUtil.format(DateUtil.endOfWeek(date), "yyyy/M/d"));
					if (!trendData.containsKey(weekDate)) {
						trendData.put(weekDate,BigDecimal.ZERO);
					}
				});
			}else {
				// 月
				List<DateTime> rangeDate = DateUtil.rangeToList(DateUtil.parse(queryDTO.getStartDate()), DateUtil.parse(queryDTO.getEndDate()), DateField.MONTH);
				rangeDate.forEach(date -> {
					String monthDate = String.format("%s月",DateUtil.format(date, "yyyy年M"));
					trendData.put(monthDate, BigDecimal.ZERO);
				});
			}
			init.setTrendData(trendData);

			initList.add(init);
		}
		return initList;
	}
}
